<?php


namespace app\common\model;


use think\Model;

class UserLogin extends Model
{
    protected $pk = 'id';
   // protected $autoWriteTimestamp = 'datetime';

    /**
     * 用户登录记录
     **/
    public function loginLog($userid){

        $num = $this->where(['user_id'=>$userid])->count('id'); //之前登录次数 不算这次登录
        //登录日志记录
        $this->save([
            'user_id'=>$userid,
            'login_ip'=>request()->ip(),//注册ip
            'device'=>request()->header('user-agent'),
            'driver'=>1, // 1=>小程序 2=>app 1=>小程序
            'is_login'=>1, // 1=>登录 ，0=>不登录
        ]);
        return $num;
    }
}